/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import Server.BUS.StringUlti;
import Server.DTO.UpdateHaveWhereQuery;
import org.junit.*;
import static org.junit.Assert.*;

/**
 *
 * @author Trung
 */
public class UpdateHaveWhereQueryTest {
    
    public UpdateHaveWhereQueryTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }
    
    @Before
    public void setUp() {
    }
    
    @After
    public void tearDown() {
    }

    @Test
    public void testUpdateHaveWhereQueryContructor1() {
        // TODO review the generated test code and remove the default call to fail.
        String queryString = "UPDATE TableA SET id = 2, name = \"abc\" WHERE id = 2";
        queryString = StringUlti.formatString(queryString);
        
        UpdateHaveWhereQuery update = new UpdateHaveWhereQuery(queryString);
        
        assertTrue(update.queryString.equalsIgnoreCase(queryString));
        assertTrue(update.keyWord.equalsIgnoreCase("UPDATE_HAVEWHERE"));
        assertTrue(update.setString.equalsIgnoreCase("id = 2, name = \"abc\""));
        assertTrue(update.updateString.equalsIgnoreCase("TableA"));
        assertTrue(update.getWhereString().equalsIgnoreCase("id = 2"));
    }
    
    @Test
    public void testUpdatehaveWhereQueryContructor2() {
        // TODO review the generated test code and remove the default call to fail.
        String queryString = "    UPDATE    TableA SET    id = 2, name = \"abc\" WHERE     id = 2   ";
        queryString = StringUlti.formatString(queryString);
        
        UpdateHaveWhereQuery update = new UpdateHaveWhereQuery(queryString);
        
        assertTrue(update.queryString.equalsIgnoreCase(queryString));
        assertTrue(update.keyWord.equalsIgnoreCase("UPDATE_HAVEWHERE"));
        assertTrue(update.setString.equalsIgnoreCase("id = 2, name = \"abc\""));
        assertTrue(update.updateString.equalsIgnoreCase("TableA"));
        assertTrue(update.getWhereString().equalsIgnoreCase("id = 2"));
    }
}
